package cn.song.service;

import cn.song.dao.GirlRepository;
import cn.song.domain.Girl;
import cn.song.enums.ErrorEnum;
import cn.song.girlexception.GiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class GirlService {

    @Autowired
    private GirlRepository girlRepository;

    public Object findid(Integer id){
        Girl girl = girlRepository.findOne(id);
        if(girl.getAge()<10){
            throw  new GiException(ErrorEnum.XIAO_SCHOOL);
        }else if(10< girl.getAge() && girl.getAge()<18){
            throw  new GiException(ErrorEnum.MIDDLE_SCHOOL);
        }else {
            return  girl;
        }

    }
}
